package com.elvin.zoe.pojo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public abstract class Message {

    public static final int OUTGOING = 1;
    public static final int INCOMMING = 2;

    protected Date datetime;
    protected String datetimeString;
    protected String datetimeFormat = "EEE, MMM d, yyyy 'at' hh:mm aaa";
    protected int type;
    protected SimpleDateFormat simpleDateFormat;

    protected int messageNumber;

    public Date getDateTime() {
        return datetime;
    }

    public String getDatetimeString() {
        return datetimeString;
    }

    public void setDatetimeString(String datetimeString) throws ParseException {
        this.datetimeString = datetimeString;
        this.simpleDateFormat = new SimpleDateFormat(datetimeFormat);
        this.datetime = parseDatetime(datetimeString);
    }

    private Date parseDatetime(String datetimeString) throws ParseException {
        return simpleDateFormat.parse(datetimeString);
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getDatetimeFormat() {
        return datetimeFormat;
    }

    public void setDatetimeFormat(String datetimeFormat) {
        this.datetimeFormat = datetimeFormat;
    }

    public int getMessageNumber() {
        return messageNumber;
    }

    public void setMessageNumber(int messageNumber) {
        this.messageNumber = messageNumber;
    }

}
